﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicClass;
using S.Services.SheepMale.Domain.PurchaseSales;
using S.Services.SheepMale.Read.Api.Application.ReadCommand.ReadMarketCommand;

namespace S.Services.SheepMale.Read.Api.Controllers
{
    /// <summary>
    /// 个体销售管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReadMarketController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReadMarketController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 个体销售显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> HandleShowMarket([FromQuery]MarketShowCommand request, CancellationToken cancellationToken)
        {
            return Ok(await mediator.Send(request));
        }
        /// <summary>
        /// 个体销售统计
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
		public async Task<IActionResult> HandleGetCount([FromQuery]MarketCountCommand request, CancellationToken cancellationToken)
		{
            return Ok(await mediator.Send(request));
		}
        /// <summary>
        /// 个体销售反填
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
		public async Task<IActionResult> HandleGetMarket([FromQuery]MarketGetCommand request, CancellationToken cancellationToken)
		{
			return Ok(await mediator.Send(request));
		}
	}
}
